<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .box {
            width: 100px;
            height: 100px;
            background-color: red;
            margin: 0 auto;
        }
    </style>
</head>
<body>
<div class="box">

</div>
<script>
    let box = document.querySelector(".box");
    // box.onclick=function () {
    //     console.log(this)
    //     _this = this
    //     setInterval(function (){
    //         console.log(this)
    //         //让颜色变为粉色
    //         _this.style.backgroundColor="pink"
    //     },2000)
    // }
    box.onclick=function (){
        console.log(this)
        setInterval(()=>{
            console.log(this)
            this.style.backgroundColor="pink"
        },2000)
    }
</script>
</body>
</html>